class Count {
  constructor(limit){

    this.limit = limit
  }
  
  [Symbol.iterator](){
    let count = 1,
        limit = this.limit;
    return {
      next(){
        if(count <= limit){
          return {
            done:false,
            value:count++
          }
        }else{
          return {
            done:true,
            value:undefined
          }
        }
      }
    }
  }
}
let b = [1,2,3,4]
let counter = new Count(4)
let counter1 = new Count(8)
for(let i of counter){
  console.log(i)
}
for(let i of counter){
  console.log(i)
}
// for(let i of counter1){
//   console.log(i)
// }
// console.log(counter.next())